package com.xing.binbackend.topology.remote;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

@Component
public class CmdbClientService {

    private final ObjectMapper mapper;

    public CmdbClientService(ObjectMapper mapper) {
        this.mapper = mapper;
    }

    public List<JsonNode> queryInstances(String ip, String className, List<String> list,
                                         String condition) {
        List<JsonNode> nodes = new ArrayList<>();
        ObjectNode node1 = mapper.createObjectNode();
        node1.put("name", "ManageOne");
        node1.put("id", "9E9E9E9E9E9E9E9E9E");
        nodes.add(node1);
        ObjectNode node2 = mapper.createObjectNode();
        node2.put("name", "OpenStack");
        node2.put("id", "6B6B6B6B6B6B6B6B6B");
        nodes.add(node2);
        return nodes;
    }

    public List<JsonNode> queryRelations(String ip, String className, List<String> list,
                                         String condition) {
        List<JsonNode> nodes = new ArrayList<>();
        ObjectNode node1 = mapper.createObjectNode();
        node1.put("name", "ManageOne");
        node1.put("id", "9E9E9E9E9E9E9E9E9E");
        nodes.add(node1);
        ObjectNode node2 = mapper.createObjectNode();
        node2.put("name", "OpenStack");
        node2.put("id", "6B6B6B6B6B6B6B6B6B");
        nodes.add(node2);
        return nodes;
    }
}
